//
// Created by webturing on 2024/3/17.
//
#include<bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    for (int n; cin >> n;) {
        vector<pair<int, int>> a(n);

        for (auto &p: a) {
            cin >> p.first >> p.second;
        }
        sort(a.begin(), a.end(), [](const pair<int, int> &p, const pair<int, int> &q) {
            return p.first < q.first;
        });
        vector<bool> book(n, false);
        int tot = 0, cnt = 0;
        for (cnt = 0; cnt < n;) {
            // if (cnt == n)break;
            ++tot;
            int start = 0;
            for (int i = 0; i < n; i++) {
                if (book[i] || a[i].first < start)continue;
                start = a[i].second;
                book[i] = true;
                ++cnt;
            }
        }
        cout << tot << endl;
    }

    return 0;

}